import XThirdLogin from './XThirdLogin'
import store from '../store/index'

export default {
    /**
     *  是否手机登录
     * @returns {*}
     */
    isPhoneLogin() {
        let user = store.getters.currentUserFn
        return !!user && user != null && user && user.userId
    },
    /**
     *  是否第三方登录
     * @returns {*}
     */
    isThirdLogin() {
        let third = store.getters.currentThirdFn
        return !!third && third != null && third && third.thirdId
    },
    /**
     *  是否登录
     * @returns {*}
     */
    isLogin() {
        return this.isPhoneLogin() || this.isThirdLogin()
    },
    /**
     *  打开手机登录
     * @returns {*}
     */
    toPhoneLogin() {
        if (!this.isPhoneLogin()) {
            window.location.href = "/to/login"
            return true
        }
        return false
    },
    /**
     *  打开第三方登录
     * @returns {*}
     */
    toThirdLogin() {
        if (!this.isThirdLogin()) {
            XThirdLogin.toLogin();
            return true
        }
        return false
    },
    /**
     *  打开登录
     * @returns {*}
     */
    toLogin() {
        return this.toThirdLogin() && this.toPhoneLogin()
    },
}
